# coding: utf-8
from typing import Union, Any


class BaseModel(object):
    def __getitem__(self, item: str):
        return getattr(self, item)

    def __setitem__(self, key: str, value: Any):
        setattr(self, key, value)

    def __delitem__(self, key: str):
        delattr(self, key)

    def __contains__(self, item: str) -> bool:
        return hasattr(self, item)

    def __repr__(self) -> str:
        return str(self.__dict__)

    def __str__(self) -> str:
        return str(self.__dict__)

    def __eq__(self, other: Union['BaseModel', dict]) -> bool:
        if isinstance(other, BaseModel):
            return self.__dict__ == other.__dict__
        elif isinstance(other, dict):
            return self.__dict__ == other
        else:
            return False

    def __ne__(self, other: Union['BaseModel', dict]) -> bool:
        return not self.__eq__(other)

    def to_dict(self) -> dict:
        return self.__dict__
